package com.jshoperxms.components.upload.qiniu;

import com.qiniu.common.QiniuException;
import com.qiniu.storage.BucketManager;
import com.qiniu.storage.model.FileListing;
import com.qiniu.util.Auth;
import org.springframework.stereotype.Component;


/**
 * Created by sdywcd on 2017/10/21.
 * Des:七牛资源获取工具类
 */
@Component
public class QiNiuResourcesTools {

    public FileListing getQiniuResouresFiles(){
        Auth auth = Auth.create(QiNiuConfig.ACCESS_KEY, QiNiuConfig.SECRET_KEY);
        BucketManager bucketManager = new BucketManager(auth);
        String prefix="";
        int limit=1000;
        String delimiter="";
        //列举空间文件列表
        try {
            FileListing fileListing=bucketManager.listFiles(QiNiuConfig.BUCKETNAME,prefix,null,limit,delimiter);
            return fileListing;
        } catch (QiniuException e) {
            e.printStackTrace();
        }
        return null;

    }
}
